// JavaScript Document
tXHR=0;   
divId="";

function XMLHTTPRequest() {   
if (window.XMLHttpRequest) {   
	a=new XMLHttpRequest(); } //Objeto nativo (FF/Safari/Opera7.6+)   
else {   
  try {   
	 a=new ActiveXObject("Msxml2.XMLHTTP");  //activeX (IE5.5+/MSXML2+)   
  }     
  catch(e) {   
	try {   
	   a=new ActiveXObject("Microsoft.XMLHTTP"); //activeX (IE5+/MSXML1)   
	}     
	catch(e) { /* O navegador não tem suporte */   
	   a=false;   
	}   
  }   
}   
return a;   
}   

function recebeResultado() {
  if (!tXHR) {
	  return false;
  }
  else {
	  if (tXHR.readyState == 4) {
		  if (tXHR.status == 200) {
			  document.getElementById(divId).innerHTML = tXHR.responseText;
		  }   
		  else {   
			  document.getElementById(divId).innerHTML = 'Erro! "'+ tXHR.statusText +'" (erro '+ tXHR.status +')';   
		  }   
	  }       
  }   
}   

function acaoConteudo(action,div,parameters) { 
  divId = div;
  tXHR=XMLHTTPRequest();   
  if (tXHR) {
	  document.getElementById(divId).innerHTML = 
          "<table align='center' valign='center'>"+
          	"<tr>"+
           		"<td align='center'>"+
                 	"<img src='image/ajax-loader.gif' />"+
                "</td>"+
			"</tr>"+
			"<tr>"+
				"<td align='center'>"+
                 	"<font color='#97C46F'><b>Carregando</b></font>"+
                "</td>"+
            "</tr>"+
          "</table>";
	  
	  tXHR.onreadystatechange=recebeResultado; 
	  tXHR.open("POST", action, true);
	  tXHR.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
	  
	  if(parameters != null){
	  	tXHR.setRequestHeader("Content-length", parameters.length);
	  }
	  
	  tXHR.setRequestHeader("Connection", "close");
      tXHR.send(parameters);   
  }   
} 

function injetar(arquivo,div){
	var injetado = document.createElement('script');
	injetado.src=arquivo;
	document.getElementById(div).appendChild(injetado);
}